﻿@model Topic
@{
	ViewBag.Title = Model.Title;
	ViewBag.HasPostAccess = Model.HasPostAccess(Role);
}
@section Head{
	@Html.MetaDescription(Utils.Summarize(Utils.RemoveTags(Model.Description), 160, ""))
}
<ul class="path">
	<li class="first">@Html.ActionLinkLocalized("Forums", "List", "Forums")</li>
	<li>@Html.ActionLink(Model.Forum.Name, "Detail", "Forums", new{forum=Model.Forum.ShortName}, null)</li>
</ul>
<div class="topicDetail">
	@if (Model.IsClosed)
	{
		<h2>@T("This thread is closed.")</h2>
	}
	<h1>@ViewBag.Title</h1>
	<div class="options">
		<a rel="nofollow" href="@Url.Action("LatestMessages")">@Html.Img("~/images/iconrss.gif", "rss")</a>
	</div>
	<div class="topicPost">
		<div class="info">
			@if (Model.User.Photo != null)
			{
				<div class="photo">
					<a href="@Url.Action("Detail", "Users", new { id=Model.User.Id})">
						<img src="@Model.User.Photo" alt="@Model.User.UserName" /></a>
				</div>
			}
			else
			{
				<div class="nophoto"><span></span></div>
			}
			<span class="postedBy">@T("Posted by")</span>
			<strong class="userName">@Html.ActionLink(Model.User.UserName, "Detail", "Users", new{id=Model.User.Id}, new{rel="nofollow"})</strong>
			<span class="separator">-</span>
			@Html.Date(Model.Date)
			<div class="groupName"><span>@Model.User.RoleName</span></div>
			<div class="memberSince">@T("Member for:") @Html.Partial("SinceDate", Model.User.RegistrationDate)</div>

		</div>
		<div class="description">
			@Html.Raw(Model.Description)
		</div>
	</div>
	@if (Model.Messages.Count > 0)
	{
		<ul id="messages">
			@foreach (Message m in Model.Messages)
			{
				Html.RenderPartial("MessageItem", m);
			}
		</ul>
	}
	@if (Model.Replies > 0)
	{
		<div class="pagerSummary">
			@T("Displaying <span class=\"firstItem\">{0}</span> to <span class=\"lastItem\">{1}</span> of <span class=\"totalItems\">{2}</span> messages",
			   PageIndex * Config.UI.MessagesPerPage + 1,
			   PageIndex * Config.UI.MessagesPerPage + Model.Messages.Count,
			   Model.Replies)
		</div>
	}
	<div id="pagerClient" style="display:none;"><a href="#" onclick="pager.more();return false;">@Html.Img("~/images/loadingMini.gif", "") @T("Show more messages")</a></div>
	@Html.Pager(Config.UI.MessagesPerPage, PageIndex, Model.Replies, S("Previous"), S("Next"))
	@Html.Partial("Toolbar")
	


	@Html.Partial("Related")
</div>
@Html.Script("~/scripts/overtip.js")
@Html.Script("~/scripts/pager.js")
@Html.Script("~/scripts/quoting.js")
<script type="text/javascript">
	$(document).ready(function ()
	{
		quoting.init();
		pager.init('@Url.Action("PageMore", "Topics", new{id=Model.Id})', '@Url.Action("PageUntil", "Topics", new{id=Model.Id})', '@T("The browser has lost session, click ok to return to the login page")');
	});
</script>
<script type="text/javascript">
	$(document).ready(function ()
	{
		$("#messages li")
			.live("tap", function () { $(this).toggleClass("over"); })
			.live("mouseenter", function () { $(this).css("background-color","").addClass("over"); })
			.live("mouseleave", function () { $(this).removeClass("over"); });
	});
	function flagMessage(mid, url)
	{
		$.post(url, { mid: mid }, function (data)
		{
			alert('@T("Thanks you, a moderator will review the message.")');
		});
		return false;
	}
	function deleteMessage(mid, url)
	{
		return deleteMessageCommon(mid, url, '@T("Are you sure you want to hide the message #{0}?")', '@T("Message removed")', null);
	}
</script>